﻿namespace S7.Net.Types
{
    using System;

    public static class Boolean
    {
        public static byte ClearBit(byte value, int bit)
        {
            return (byte) (value & ~((byte) Math.Pow(2.0, (double) bit)));
        }

        public static bool GetValue(byte value, int bit)
        {
            return ((value & ((int) Math.Pow(2.0, (double) bit))) != 0);
        }

        public static byte SetBit(byte value, int bit)
        {
            return (byte) (value | ((byte) Math.Pow(2.0, (double) bit)));
        }
    }
}

